package au.edu.unsw.editingtool.db;

import java.sql.SQLException;
import java.util.Hashtable;

import au.edu.unsw.editingtool.global.EditingToolException;

public class DBAttachment extends DBManager {
	
	private void setupDBMapping() {
		if (MappingTable.size() > 0)
			return;
		MappingTable.put("Attachment", "dsid");
		MappingTable.put("Publication", "pid");
		MappingTable.put("Status", "dsstatus");
		MappingTable.put("Editor", "editor");
		MappingTable.put("FedoraVersion", "fedora_version");
	}
	
	public DBAttachment() {
		this.table = "attachment";
		this.primaryKeys = new String[]{"Attachment"};
		this.setupDBMapping();
	}
	
	public void addAttachment(Hashtable<String, String> attachment) throws EditingToolException, SQLException, ClassNotFoundException {
		this.setTable(this.table, "");
		this.setColumnValues(attachment);		
		this.initDB();
		this.insert(false, false);
		this.clean();
	}
}
